<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    body{
      background:red;
      color: #fff;
    }
    .mainBox {
      left: 50%;
      margin-left: -450px;
      position: fixed;
      font-size: 120px;
      width: 100%;
      text-align: center;
      top: 18%;
      padding: 20px;
      width: 900px;
    }

    .timeBox {
      margin: auto;
      margin-top: 30px;
      font-size: 150px;
      border: 4px solid #fff;
      max-width: 700px;
      line-height: 1.5;
    }

  </style>
</head>

<body>

  <div class="mainBox">
    <div class="dateBox"></div>
    <div class="timeBox"></div>
  </div>


  <script>
    Date.prototype.Format = function (fmt) {
      var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
      };
      if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
      for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((
          "00" + o[k]).substr(("" + o[k]).length)));
      return fmt;
    };
    (function () {
      var dateBox = document.querySelector(".dateBox");
      var timeBox = document.querySelector(".timeBox");
      var app = {
        setDate: function () {
          var date = new Date();
          var date1 = new Date().Format("yyyy-MM-dd");
          dateBox.innerHTML = date1
        },
        setTime: function () {
          var date = new Date();
          var date2 = new Date().Format("hh:mm:ss");
          timeBox.innerHTML = date2
        },
        init: function () {
          var self = this;
          setInterval(function () {
            self.setDate()
            self.setTime()
          }, 1000)
        }
      }
      app.init();
    })();

  </script>
</body>

</html>
